package com.yzc.controller;


import com.yzc.model.query.order.TOrdersReq;
import com.yzc.model.vo.order.TOrdersVo;
import com.yzc.result.Result;
import com.yzc.result.ResultCodeEnum;
import com.yzc.service.TOrdersService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/order")
public class TOrdersController {
    @Autowired
    private TOrdersService tOrdersService;

    @GetMapping("/loadAllOrderList")
    public Result<List<TOrdersVo>> loadAllOrderList() {
        List<TOrdersVo> list = tOrdersService.loadAllOrderList(); // 假设返回的是List<TOrders>
        log.info("加载所有订单信息");
        return Result.success(list); // 返回包含所有复制对象的新列表
    }
    @PostMapping("/saveOrderInfo")
    public Result saveOrderInfo(@RequestBody TOrdersReq tOrdersReq) {
        try {
            tOrdersService.saveOrderInfo(tOrdersReq);
            log.info("保存订单信息");
            return Result.success();
        } catch (Exception e) {
            return Result.fail(ResultCodeEnum.FAIL);
        }
    }
}
